add.js ➔ getPlaceByElem   C
last analyzed

Complexity

Conditions 11
Paths 7

Size

Total Lines 18
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 18
rs 5.4
c 0
b 0
f 0
cc 11
nc 7
nop 1

How to fix   Complexity   

Complexity

Complex classes like add.js ➔ getPlaceByElem often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

1
function detectmob() {
2
3
    return navigator.userAgent.match(/Android/i)
0 ignored issues
show
Bug introduced by
The variable navigator seems to be never declared. If this is a global, consider adding a /** global: navigator */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
4
        || navigator.userAgent.match(/webOS/i)
5
        || navigator.userAgent.match(/iPhone/i)
6
        || navigator.userAgent.match(/iPad/i)
7
        || navigator.userAgent.match(/iPod/i)
8
        || navigator.userAgent.match(/BlackBerry/i)
9
        || navigator.userAgent.match(/Windows Phone/i);
10
}
11
12
function setModalHeader(e_slug, h_type) {
13
    $.post(Routing.generate('get_modal_header', {slug: e_slug, headerType:h_type}), function (data) {
0 ignored issues
show
Bug introduced by
The variable Routing seems to be never declared. If this is a global, consider adding a /** global: Routing */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
14
        if (data.result) {
15
            $('.change-title').html(data.html);
16
        } else {
17
            console.log('Error:'+data.error);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
18
        }
19
    });
20
}
21
22
function popupwindow(url, title, w, h) {
23
    var left = (screen.width/2)-(w/2);
0 ignored issues
show
Bug introduced by
The variable screen seems to be never declared. If this is a global, consider adding a /** global: screen */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
24
    var top = (screen.height/2)-(h/2);
25
    return window.open(url, title, 'width='+w+', height='+h+', top='+top+', left='+left);
26
}
27
28
function setPaymentHtmlbyData(data, e_slug) {
29
    $('#payment').data('pay-type', data.pay_type).attr('action', data.form_action);
30
    $('#pay-form').html(data.html).data('event', e_slug);
31
    $('#payment-sums').html(data.paymentSums);
32
    $('#cancel-promo-code').click();
33
    $('#cancel-add-user').click();
34
    $('#user_phone').val(data.phoneNumber);
35
    var buy_btn = $('#buy-ticket-btn');
36
    if (data.form_action === '') {
37
        buy_btn.prop("disabled", true);
38
    } else {
39
        buy_btn.prop('disabled', false);
40
    }
41
    buy_btn.html(data.byeBtnCaption);
42
    var old_event = buy_btn.data('event');
43
    if (old_event) {
44
        buy_btn.removeClass('event-'+old_event);
45
    }
46
47
    buy_btn.addClass('event-'+e_slug).data('event', e_slug);
48
    if (!data.is_user_create_payment) {
49
        $('#add-user-trigger').hide();
50
        $('#promo-code-trigger').hide();
51
    }
52
}
53
54
function getPlaceByElem(elem) {
55
    if (elem) {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if elem is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
56
        var place = 'social';
57
        if (elem.hasClass('cost__buy--mob')) {
58
            place = 'event_pay_mob';
59
        } else if (elem.hasClass('cost__buy')) {
60
            place = 'event_pay';
61
        } else if (elem.hasClass('event_fix_header_mob') || elem.hasClass('event-action-mob__btn')
62
            || elem.hasClass('fix-event-header__btn--mob')) {
63
            place = 'event_mob';
64
        } else if (elem.hasClass('fix-event-header__btn') || elem.hasClass('event-header__btn')) {
65
            place = 'event';
66
        } else if (elem.hasClass('event-card__btn') || elem.hasClass('event-row__btn')) {
67
            place = 'main';
68
        }
69
        return place;
70
    }
71
}
72
73
function setPaymentHtml(e_slug, mobForce) {
74
    var inst = $('[data-remodal-id=modal-payment]').remodal();
75
    var promocode = Cookies.get('promocode');
0 ignored issues
show
Bug introduced by
The variable Cookies seems to be never declared. If this is a global, consider adding a /** global: Cookies */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
76
    var promoevent = Cookies.get('promoevent');
77
    var route = '';
78
    if (promocode && promoevent === e_slug) {
79
        route = Routing.generate('event_pay', {eventSlug: e_slug, promoCode: promocode});
0 ignored issues
show
Bug introduced by
The variable Routing seems to be never declared. If this is a global, consider adding a /** global: Routing */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
80
    } else {
81
        route = Routing.generate('event_pay', {eventSlug: e_slug});
82
    }
83
    $.ajax({
84
        type: 'GET',
85
        url: route,
86
        success: function (data) {
87
            if (data.result) {
88
                setPaymentHtmlbyData(data, e_slug);
89
                if (data.tickets_count === 0) {
90
                    $('#add-user-trigger').click();
91
                }
92
                if (!detectmob() && !mobForce) {
93
                    inst.open();
94
                }
95
                return true;
96
            } else {
0 ignored issues
show
Comprehensibility introduced by
else is not necessary here since all if branches return, consider removing it to reduce nesting and make code more readable.
Loading history...
97
                if (data.error_code === 1) {
98
                    window.location.pathname = homePath+"static-payment/"+e_slug;
0 ignored issues
show
Bug introduced by
The variable homePath seems to be never declared. If this is a global, consider adding a /** global: homePath */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
99
                }
100
                console.log('Error:' + data.error);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
101
                if (!detectmob() && !mobForce) {
102
                    inst.close();
103
                }
104
105
                return false;
106
            }
107
        },
108
        error: function(jqXHR, textStatus, errorThrown) {
0 ignored issues
show
Unused Code introduced by
The parameter errorThrown is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
Unused Code introduced by
The parameter textStatus is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
109
            switch (jqXHR.status) {
110
                case 401:
111
                    if (detectmob()) {
112
                        window.location.search = "?exception_login=1";
113
                        window.location.pathname = homePath+"login";
0 ignored issues
show
Bug introduced by
The variable homePath seems to be never declared. If this is a global, consider adding a /** global: homePath */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
114
                    } else {
115
                        var inst = $('[data-remodal-id=modal-signin-payment]').remodal();
116
                        inst.open();
117
                    }
118
                    break;
119
                case 403: window.location.reload(true);
120
            }
121
            return false;
122
        }
123
    });
124
}
125
126
function setSpeakerHtml(e_slug, s_slug, with_review) {
127
    var inst = $('[data-remodal-id=modal-speaker]').remodal();
128
    $.get(Routing.generate('speaker_popup', { eventSlug: e_slug, speakerSlug:s_slug, withReview:with_review}),
0 ignored issues
show
Bug introduced by
The variable Routing seems to be never declared. If this is a global, consider adding a /** global: Routing */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
129
        function (data) {
130
            if (data.result) {
131
                $('#speaker-popup-content').html(data.html);
132
                inst.open();
133
            } else {
134
                inst.close();
135
                console.log('Error:' + data.html);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
136
            }
137
        });
138
}
139
140
var registrationFormId = null;
141
142
function submitRegistrationForm(token) {
143
    if (null !== registrationFormId) {
144
        $('<input />').attr('type', 'hidden')
145
            .attr('name', "g-recaptcha-response")
146
            .attr('value', token)
147
            .appendTo('#' + registrationFormId);
148
149
        $('#' + registrationFormId).submit();
150
    }
151
}
152
153
function submitValidForm(rId, withCaptcha) {
154
    registrationFormId = rId;
155
    var form = $('#'+registrationFormId);
156
    form.validate({
157
        debug: false,
158
        errorClass: "text-error",
159
        errorElement: "p",
160
        onkeyup: false,
161
        highlight: function(element) {
162
            $(element).addClass('input--error');
163
            var p = $(element).next('p');
164
            if ($(p).hasClass('text-error') && undefined === $(p).attr('id')) {
165
                $(p).hide();
166
            }
167
        },
168
        unhighlight: function(element) {
169
            $(element).removeClass('input--error');
170
            var p = $(element).next('p');
171
            if ($(p).hasClass('text-error') && undefined === $(p).attr('id')) {
172
                $(p).hide();
173
            }
174
        }
175
    });
176
177
    if (form.valid()) {
178
        if (withCaptcha) {
179
            grecaptcha.execute();
0 ignored issues
show
Bug introduced by
The variable grecaptcha seems to be never declared. If this is a global, consider adding a /** global: grecaptcha */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
180
        } else {
181
            form.submit();
182
        }
183
    }
184
}
185
186
$(document).on('submit', '#payment', function (e) {
187
    var form = $(this);
188
    if (form.data('pay-type') === 'wayforpay') {
189
        e.preventDefault();
190
        if (!detectmob()) {
191
            var inst = $('[data-remodal-id=modal-payment]').remodal();
192
            inst.close();
193
        }
194
        paymentSystemPay();
195
    }
196
});
197
198
199
$(document).on('click', '.user-payment__remove', function () {
200
    var elem = $(this);
201
    var e_slug = $('#pay-form').data('event');
202
    $.post(Routing.generate('remove_ticket_from_payment',
0 ignored issues
show
Bug introduced by
The variable Routing seems to be never declared. If this is a global, consider adding a /** global: Routing */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
203
        {
204
            eventSlug: e_slug,
205
            id: elem.data('ticket')
206
        }),
207
        function (data) {
208
            if (data.result) {
209
                setPaymentHtmlbyData(data, e_slug)
210
            } else {
211
                console.log('Error:'+data.error);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
212
            }
213
        });
214
});
215
216
$(document).on('click', '.social-login', function () {
217
    var elem = $(this);
218
    if (elem.hasClass('bye-after-login')) {
219
        Cookies.set('bye-event', 'event');
0 ignored issues
show
Bug introduced by
The variable Cookies seems to be never declared. If this is a global, consider adding a /** global: Cookies */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
220
    } else {
221
        Cookies.remove('bye-event', { path: '/', http: false, secure : false });
222
    }
223
});
224
225
var hideTimer = null;
226
227
function hideFlash(text) {
228
    $('#flash-user').removeClass('alert--show').fadeOut(400, function () {
229
        $('#flash-user-content').html(text);
230
    });
231
}
232
233
function showFlash() {
234
    $('#flash-user').addClass('alert--show').fadeIn();
235
}
236
237
function setFlashTextAndShow(text) {
238
    var flashDiv = $('#flash-user');
239
    if (flashDiv.hasClass('alert--show')) {
240
        hideFlash(text);
241
    } else {
242
        $('#flash-user-content').html(text);
243
    }
244
    showFlash();
245
    if (hideTimer) {
246
        clearTimeout(hideTimer);
247
    }
248
    hideTimer = setTimeout(hideFlash, 3000);
249
}
250
251
$(document).on('click', '.alert__close', function () {
252
    hideFlash();
253
    if (hideTimer) {
254
        clearTimeout(hideTimer);
255
    }
256
});
257
258
$(document).on('click', '.add-wants-visit-event', function () {
259
        var elem = $(this);
260
        var e_slug = elem.data('event');
261
        $.ajax({
262
            type: 'POST',
263
            url: Routing.generate('add_wants_to_visit_event', { slug: e_slug}),
0 ignored issues
show
Bug introduced by
The variable Routing seems to be never declared. If this is a global, consider adding a /** global: Routing */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
264
            success: function(data) {
265
                if (data.result) {
266
                    $('.add-wants-visit-event').each(function() {
267
                        if ($( this ).data('event') === e_slug) {
268
                            $( this ).removeClass('add-wants-visit-event').addClass('sub-wants-visit-event').html(data.html);
269
                        }
270
                    });
271
                    setFlashTextAndShow(data.flash);
272
                } else {
273
                    console.log('Error:'+data.error);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
274
                }
275
            },
276
            error: function(jqXHR, textStatus, errorThrown) {
0 ignored issues
show
Unused Code introduced by
The parameter errorThrown is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
Unused Code introduced by
The parameter textStatus is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
277
                switch (jqXHR.status) {
278
                    case 401:
279
                        if (detectmob()) {
280
                            window.location.href = homePath+"login?exception_login=1";
0 ignored issues
show
Bug introduced by
The variable homePath seems to be never declared. If this is a global, consider adding a /** global: homePath */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
281
                        } else {
282
                            var inst = $('[data-remodal-id=modal-signin-payment]').remodal();
283
                            inst.open();
284
                        }
285
                        break;
286
                    case 403:
287
                        window.location.reload(true);
288
                }
289
            }
290
        });
291
});
292
293
$(document).on('click', '.sub-wants-visit-event', function () {
294
        var elem = $(this);
295
        var e_slug = elem.data('event');
296
        $.post(Routing.generate('sub_wants_to_visit_event', {slug: e_slug}), function (data) {
0 ignored issues
show
Bug introduced by
The variable Routing seems to be never declared. If this is a global, consider adding a /** global: Routing */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
297
            if (data.result) {
298
                $('.sub-wants-visit-event').each(function() {
299
                    if ($( this ).data('event') === e_slug) {
300
                        $( this ).removeClass('sub-wants-visit-event').addClass('add-wants-visit-event').html(data.html);
301
                    }
302
                });
303
                setFlashTextAndShow(data.flash);
304
            } else {
305
                console.log('Error:'+data.error);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
306
            }
307
        });
308
});
309
310
$('[data-testid="dialog_iframe"]').on('load', function() {
311
    $(this).removeClass('fb_customer_chat_bounce_in').addClass('fb_customer_chat_bounce_out').hide();
312
});
313
314
$(document).ready(function () {
315
    $('.add_recapcha').on('click', function () {
316
        var s = $("<script></script>");
317
        s.attr('src', 'https://www.google.com/recaptcha/api.js?hl='+locale);
0 ignored issues
show
Bug introduced by
The variable locale seems to be never declared. If this is a global, consider adding a /** global: locale */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
318
        s.prop('async', true);
319
        s.prop('defer', true);
320
        $("body").append(s);
321
    });
322
323
    $('#share-ref__facebook').on('click', function () {
324
        popupwindow('http://www.facebook.com/sharer/sharer.php?u='+$('#ref-input').val(), 'facebook', 500, 350);
325
    });
326
327
    $('.mask-phone-input--js').bind('input', function() {
328
        $(this).val(function(_, v){
329
            return v.replace(/[-\s\(\)]+/g, '');
330
        });
331
    }).on('focus', function () {
332
        if ($(this).val() === '') {
333
            $(this).val('+380');
334
        }
335
    }).on('focusout', function () {
336
        if ($(this).val() === '+380') {
337
            $(this).val('');
338
        }
339
    });
340
341
    $.validator.methods.email = function( value, element ) {
342
        return this.optional( element ) || /^\w([\-\.]{0,1}\w)*\@\w+([\-\.]{0,1}\w)*\.\w{2,4}$/.test( value );
343
    };
344
345
    $('#payment').validate({
346
        debug: false,
347
        errorClass: "text-error",
348
        errorElement: "p",
349
        onkeyup: false,
350
        highlight: function(element) {
351
            $(element).addClass('input--error');
352
        },
353
        unhighlight: function(element) {
354
            $(element).removeClass('input--error');
355
        }
356
    });
357
358
    $.validator.addClassRules({
359
        'valid-name': {
360
            required: true,
361
            pattern: /^[A-Za-zА-Яа-яЁёІіЇїЄє\-\s']+$/,
362
            minlength: 2,
363
            maxlength: 32,
364
        },
365
        'valid-plainPassword' : {
366
            required: true,
367
            minlength: 2,
368
            maxlength: 72,
369
        },
370
        'valid-email' : {
371
            required: true,
372
            email: true,
373
        },
374
        'valid-phone' : {
375
            required: false,
376
            minlength: 12,
377
            maxlength: 16,
378
            pattern: /\+[1-9]{1}[0-9]{10,14}$/i,
379
        }
380
    });
381
382
    $('#user_promo_code').rules("add", {
383
        minlength: 2,
384
        messages: {
385
            minlength: $.validator.format(Messages[locale].CORRECT_MIN),
0 ignored issues
show
Bug introduced by
The variable Messages seems to be never declared. If this is a global, consider adding a /** global: Messages */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Bug introduced by
The variable locale seems to be never declared. If this is a global, consider adding a /** global: locale */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
386
            required: Messages[locale].FIELD_REQUIRED,
387
        }
388
    });
389
390
    $('.open-speaker-popup').on('click', function () {
391
        var speakerElement = $('.speaker-card__top[data-speaker='+$(this).data('speaker')+']'),
392
             e_slug = speakerElement.data('event'),
393
             s_slug = speakerElement.data('speaker'),
394
             with_review = speakerElement.data('review');
395
        setSpeakerHtml(e_slug, s_slug, with_review);
396
    });
397
398
    $('.speaker-card__top').on('click', function () {
399
        var e_slug = $(this).data('event');
400
        var s_slug = $(this).data('speaker');
401
        var with_review = $(this).data('review');
402
        setSpeakerHtml(e_slug, s_slug, with_review);
403
    });
404
405
    $('.set-modal-header').on('click', function () {
406
        var e_slug = $(this).data('event');
407
        var h_type = '';
408
        if ($(this).hasClass('get-payment')) {
409
            h_type = 'buy';
410
        } else {
411
            h_type = 'reg';
412
        }
413
        setModalHeader(e_slug, h_type);
414
    });
415
416
    $('.get-payment').on('click', function () {
417
        var elem = $(this);
418
        var e_slug = elem.data('event');
419
        var promocode = Cookies.get('promocode');
0 ignored issues
show
Bug introduced by
The variable Cookies seems to be never declared. If this is a global, consider adding a /** global: Cookies */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
420
        var promoevent = Cookies.get('promoevent');
421
        if (detectmob()) {
422
            var queryParams = '';
423
            if (promocode && promoevent === e_slug) {
424
                queryParams = '?promocode='+promocode;
425
            }
426
            window.location.pathname = homePath + "static-payment/" + e_slug + queryParams;
0 ignored issues
show
Bug introduced by
The variable homePath seems to be never declared. If this is a global, consider adding a /** global: homePath */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
427
        } else {
428
            setModalHeader(e_slug, 'buy');
429
            setPaymentHtml(e_slug);
430
        }
431
    });
432
433
    $('.add-promo-code-btn').on('click', function () {
434
        if ($('#user_promo_code').valid()) {
435
            var e_slug = $('#pay-form').data('event');
436
            $.post(Routing.generate('add_promo_code', {code: $("input[name='user_promo_code']").val(), eventSlug: e_slug}),
0 ignored issues
show
Bug introduced by
The variable Routing seems to be never declared. If this is a global, consider adding a /** global: Routing */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
437
                function (data) {
438
                    if (data.result) {
439
                        setPaymentHtmlbyData(data, e_slug);
440
                    } else {
441
                        var validator = $('#payment').validate();
442
                        var errors = { user_promo_code: data.error };
443
                        validator.showErrors(errors);
444
                    }
445
                });
446
        }
447
    });
448
449
    $('.add-user-btn').on('click', function () {
450
        if ($('#payment_user_name').valid() &&
451
            $('#payment_user_surname').valid() &&
452
            $('#payment_user_email').valid()) {
453
            var e_slug = $('#pay-form').data('event');
454
            $.post(Routing.generate('add_participant_to_payment',
0 ignored issues
show
Bug introduced by
The variable Routing seems to be never declared. If this is a global, consider adding a /** global: Routing */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
455
                {
456
                    eventSlug: e_slug,
457
                    name: $("input[name='user-name']").val(),
458
                    surname: $("input[name='user-surname']").val(),
459
                    email: $("input[name='user-email']").val()
460
                }),
461
                function (data) {
462
                    if (data.result) {
463
                        setPaymentHtmlbyData(data, e_slug);
464
                    } else {
465
                        var validator = $('#payment').validate();
466
                        var errors = { "user-email": data.error };
467
                        validator.showErrors(errors);
468
                    }
469
                });
470
        }
471
    });
472
473
    $('#buy-ticket-btn').on('click', function () {
474
        var use_phone = $('#user_phone').val();
475
        if (use_phone !== '' && $('#user_phone').valid()) {
476
            $.post(Routing.generate('update_user_phone', {phoneNumber: use_phone}), function (data) {
0 ignored issues
show
Unused Code introduced by
The parameter data is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
Bug introduced by
The variable Routing seems to be never declared. If this is a global, consider adding a /** global: Routing */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
477
            });
478
        }
479
    });
480
481
    $(document).on('click', '.like-btn-js', function (e) {
482
        e.preventDefault();
483
        var rv_slug = $(this).data('review');
484
        $.post(Routing.generate('like_review', {reviewSlug: rv_slug}),
0 ignored issues
show
Bug introduced by
The variable Routing seems to be never declared. If this is a global, consider adding a /** global: Routing */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
485
            function (data) {
486
                if (data.result) {
487
                    $("div[data-review='"+ rv_slug+"']").html('<i class="icon-like like-btn__icon"></i>'+data.likesCount);
488
                } else {
489
                    $("div[data-review='"+rv_slug+"']").html('<i class="icon-like like-btn__icon"></i>error');
490
                }
491
        });
492
    });
493
494
    $('iframe').each(function() {
495
        if ($(this).data('src')) {
496
            $(this).attr('src', $(this).data('src'));
497
        }
498
    });
499
});
500